

def test_signalling():
    import random
    
    def print_fnc(x):
        print x
    
    def listener(l):
        print "%s activated by %s" % (l, l.match)
        
    c = Channel(log_fnc=print_fnc, validation=True)
    c.register("foo")
    c.listen("foo", listener)
    c.emit("foo", x=0)
    
    for _ in xrange(10):
        c.listen(None, listener, priority=random.uniform(-1, 1))
    try:
        c.emit("bar")
    except ValueError, error:
        print error
        c.validation = False
        c.emit("bar")
        